/**
 * @param {string} s
 * @return {number}
 */
var myAtoi = function (s) {
  let str = s.trim()
  let max = Math.pow(2, 31) - 1
  let min = -max - 1

  let reg = /\s*([-\+]?[0-9]*).*/
  let res = str.match(reg)[1]
  if (res.length === 1 && (res[0] === '+' || res[0] === '-')) return false
  res = res * 1
  if (res > max) return max
  if (res < min) return min
  return res
};


console.log(myAtoi("-4193 with words"))